import http from '@/config/request';

export default {
  // 获取部门列表
  getDepartmentList(params) {
    // 直接拼接URL参数
    let url = '/admin/department/list';
    if (params) {
      const { current, size, name } = params;
      url += `?current=${current}&size=${size}`;
      if (name) {
        url += `&name=${encodeURIComponent(name)}`;
      }
    }
    return http.get(url);
  },
  // 新增部门
  addDepartment(data) {
    return http.post('/admin/department/create', data);
  },
  // 编辑部门
  editDepartment(data) {
    return http.put('/admin/department/update', data);
  },
  // 删除部门
  deleteDepartment(id) {
    return http.delete(`/admin/department/delete?id=${id}`);
  },
  // 获取部门员工信息列表
  getDepartmentEmployees(id) {
    return http.get(`/admin/department/employees?departmentId=${id}`);
  }
};

